/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FAA.TG.Interface;

import FAA.TG.Algoritmos.Dijkstra.Dijkstra;
import FAA.TG.Algoritmos.Grafos.Grafo;
import FAA.TG.Algoritmos.Largura.BuscaEmLargura;
import FAA.TG.Algoritmos.Profundidade.BuscaEmProfundidade;
import FAA.TG.Entrada.Parser;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;

/**
 *
 * @author Eduardo
 */
public class Principal extends javax.swing.JFrame {

    
    private Parser parser;
    private Grafo grafo;
    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItemDijkstra = new javax.swing.JMenuItem();
        jMenuItemprofundidade = new javax.swing.JMenuItem();
        jMenuItemlargura = new javax.swing.JMenuItem();

        jMenuItem4.setText("jMenuItem4");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu1.setText("Arquivo");

        jMenuItem1.setText("Carregar Arquivo");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Sair");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Algoritmos");

        jMenuItemDijkstra.setText("Dijkstra");
        jMenuItemDijkstra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDijkstraActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemDijkstra);

        jMenuItemprofundidade.setText("Profundidade");
        jMenuItemprofundidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemprofundidadeActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemprofundidade);

        jMenuItemlargura.setText("Largura");
        jMenuItemlargura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemlarguraActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemlargura);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        
        JFileChooser arquivo = new JFileChooser();
        arquivo.showOpenDialog(jMenu1);
        String teste = arquivo.getSelectedFile().getAbsoluteFile().toString();
        File arq =  new File(arquivo.getSelectedFile().getAbsoluteFile().toString());
        parser = new Parser(arq);
        
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItemlarguraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemlarguraActionPerformed
        
        //grafo = new Grafo(parser.getMatriz().length,parser.getMatriz().length);
        //parser.ParserBFSDFS(grafo);
        //grafo.imprime();
        BuscaEmLargura largura = new BuscaEmLargura(grafo);
        try {
            //largura.visitaBfs(grafo.getNumVertices(), grafo.getCab());
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jMenuItemlarguraActionPerformed

    private void jMenuItemprofundidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemprofundidadeActionPerformed
        
        //grafo = new Grafo(parser.getMatriz().length,parser.getMatriz().length);
        //parser.ParserBFSDFS(grafo);
        //grafo.imprime();
        BuscaEmProfundidade profundidade = new BuscaEmProfundidade(grafo);
        //profundidade.visitaDfs(WIDTH, WIDTH, grafo.getCab());
    }//GEN-LAST:event_jMenuItemprofundidadeActionPerformed

    private void jMenuItemDijkstraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDijkstraActionPerformed

        
        
    }//GEN-LAST:event_jMenuItemDijkstraActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItemDijkstra;
    private javax.swing.JMenuItem jMenuItemlargura;
    private javax.swing.JMenuItem jMenuItemprofundidade;
    // End of variables declaration//GEN-END:variables
}
